import os  
import os.path 
import xml.etree.ElementTree as ET
#配置参数 target_file：目标地址  path：xml存放的绝对路径或相对路径
target_file = "D:\PythonDemo\image_processing\ks\yolov5\longicorn_data\image\\"

path="xml/"


files=os.listdir(path)
i = 0
for xmlFile in files:
    tree = ET.parse(path + xmlFile)
    root = tree.getroot()
    element = root.find('path')
    filename = xmlFile.split('.')
    element.text = target_file + filename[0] + ".jpg"
    tree.write(path + xmlFile)
    print(xmlFile + ' done')
